package com.lwlean.test.mapper;

import com.lwlean.test.domain.Users;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

/**
 * Created by lean on 16-12-5.
 */
@Component
public interface UserMapper {

    String TABLE_NAME = "users";

    String ARGS_LIST = "name,password,email,phone,introduct";

    String VALUES_LIST = "#{name},#{password},#{email},#{phone},#{introduct}";

    @Select("select "+ ARGS_LIST + " from "+ TABLE_NAME + " where id=#{id}")
    Users getUser(final @Param("id") Long id);

    @Insert("insert into " + TABLE_NAME + " values (" + VALUES_LIST + ")")
    void addUser(final @Param("user") Users user);

    @Delete("delete from " + TABLE_NAME + " where id = #{id}")
    void dropUser(final @Param("id") Long id);

    @Update("update " + TABLE_NAME + " set phone = #{phone} where id = #{id}")
    void updateUser(final @Param("user") Users users);

    void updateUsers(final Users users);

}
